package com.cms.admin.action.erxinliangbiao;


import java.util.List;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.cms.admin.action.BaseAction;
import com.cms.admin.model.PatientList;
import com.cms.admin.model.RateScalesPatient;
import com.cms.admin.model.RateScalesPatientExample;
import com.cms.admin.service.erxinliangbiao.RateScalesPatientService;
import com.cms.admin.util.Constants;
import com.opensymphony.xwork2.ModelDriven;
/**
 * Created by Faroe on 2017/9/7.
 */

public class RateScalesPatientAction extends BaseAction implements ModelDriven<RateScalesPatientExample>{
    private RateScalesPatientService rateScalesPatientService;
    private List<RateScalesPatient> rateScalesPatient;
    private List<PatientList> patientList;
    private RateScalesPatientExample search = new RateScalesPatientExample();


    //获取就诊人列表
    public String erxinliangbiaoAjaxQueryPatient() {

        HttpServletRequest request = ServletActionContext.getRequest();
        String a = null;
        a = request.getParameter("userNo");
        LOG.info("电话号码是"+a);
        patientList = rateScalesPatientService.getPatientList(a);
        rateScalesPatient = rateScalesPatientService.getRateScalesPatient(a);
        try {
            JSONObject o = new JSONObject();
            o.put("content", patientList);
            o.put("rateScalesPatient",rateScalesPatient);
            return ajaxJsonSuccessMessage(o);
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxJsonErrorMessage(Constants.INFO_SYS_ERROR);
        }
    }

    //保存分数
    public String ErXinLiangBiaoSaveScoreAction (){
        LOG.info("===========================================进入");
        rateScalesPatientService.saveErXinLiangBiaoScore(search);
        try {
            JSONObject o = new JSONObject();
            return ajaxJsonSuccessMessage(o);
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxJsonErrorMessage(Constants.INFO_SYS_ERROR);
        }
    }


    @Override
    public RateScalesPatientExample getModel(){
        return search;
    }

    public RateScalesPatientExample getSearch() {
        return search;
    }

    public void setSearch(RateScalesPatientExample search) {
        this.search = search;
    }

    public List<PatientList> getPatientList() {
        return patientList;
    }

    public void setPatientList(List<PatientList> patientList) {
        this.patientList = patientList;
    }

    public RateScalesPatientService getRateScalesPatientService() {
        return rateScalesPatientService;
    }

    public void setRateScalesPatientService(RateScalesPatientService rateScalesPatientService) {
        this.rateScalesPatientService = rateScalesPatientService;
    }

    public List<RateScalesPatient> getRateScalesPatient() {
        return rateScalesPatient;
    }

    public void setRateScalesPatient(List<RateScalesPatient> rateScalesPatient) {
        this.rateScalesPatient = rateScalesPatient;
    }


}
